﻿<%@ page contentType="text/html;charset=UTF-8" language="java" %>
<%@ taglib prefix="c" uri="http://java.sun.com/jsp/jstl/core" %>
<%@ taglib prefix="fmt" uri="http://java.sun.com/jsp/jstl/fmt" %>
<c:set var="ctx" value="${pageContext.request.contextPath}"/>
<html>
<head><link rel="stylesheet" href="${ctx}/common/common.css">
    <title>Title</title>
    <link rel="stylesheet" href="${ctx}/common/plugins/layuiadmin/layui/css/layui.css" media="all">
    <link rel="stylesheet" href="${ctx}/common/plugins/layuiadmin/style/admin.css" media="all">
    <script src="${ctx}/common/plugins/layuiadmin/layui/layui.js"></script>
    
    <script src="${ctx}/common/plugins/layuiadmin/layui-xtree/layui-xtree.js"></script>
    <style type="text/css">
    	.rowtop{
    		padding: 10px
    	}
        .layui-layer-msg{
    	position:fixed!important;
    	top:50%!important;
 	   }	
    </style>
</head>
<body>
<form class="layui-form" action="${ctx}/enterprise/saveEnterprise" method="post" enctype="multipart/form-data">
    <input type="hidden" name="id" value="${tenterprise.id}" />
    <input type="hidden" name="deleteFlag" value="0" />
    <input type="hidden" name="licenceId" value="${licence1.id }">
    <input type="hidden" name="licenceId2" value="${licence2.id }">
    <div class="layui-row rowtop" style="margin-top: 20px;">
	    <div class="layui-col-md6">
	        <label class="layui-form-label">企业名称<span style="color: red">*</span></label>
	        <div class="layui-input-block">
	            <input type="text" name="name" value="${tenterprise.name}" lay-verify="required" placeholder="请输入企业名称" autocomplete="off" class="layui-input">
	        </div>
	    </div>
	    <div class="layui-col-md6">
	        <label class="layui-form-label">企业简称</label>
	        <div class="layui-input-block">
	            <input type="text" name="abbreviation" value="${tenterprise.abbreviation}" placeholder="请输入企业简称" autocomplete="off" class="layui-input">
	        </div>
	    </div>
    </div>
    <div class="layui-row rowtop">
    	<div class="layui-col-md6">
    		<label class="layui-form-label">区域<span style="color: red">*</span></label>
		  	<div class="layui-input-block">
				<div id="areaname" class="areaname" style="display: block;width: 96%;padding-left: 10px;height: 38px;background: #eee;line-height:38px">${areaname }</div>
				<input type="hidden" id="t_a_id" name="t_a_id" value="${tenterprise.t_a_id }">
				<div class="areatreeshow" style="width: 98%;max-height:300px;position: absolute;background: white;z-index: 10;border: 1px solid #e7e7e7;border-top: none;display: none;overflow: hidden;overflow-y: auto;">
					<ul id="areaTree"></ul>
				</div>
			</div>
    	</div>
    	<div class="layui-col-md6">
    		<label class="layui-form-label">行业类别<span style="color: red">*</span></label>
    		<div class="layui-input-block">
				<div id="industryname" class="industryname" style="display: block;width: 95%;padding-left: 10px;height: 38px;background: #eee;line-height:38px">${industryname }</div>
				<input type="hidden" id="t_i_id" name="t_i_id" value="${tenterprise.t_i_id }">
				<div class="industryshow" style="width: 98%;max-height:300px;position: absolute;background: white;z-index: 10;border: 1px solid #e7e7e7;border-top: none;display: none;overflow: hidden;overflow-y: auto;">
					<ul id="industryTree"></ul>
				</div>
			</div>
    	</div>
    </div>
    <div class="layui-row rowtop">
    	<div class="layui-col-md6">
    		<label class="layui-form-label">生产范围<span style="color: red">*</span></label>
    		<div class="layui-input-block">
				<div id="proclaname" class="proclaname" style="display: block;width: 95%;padding-left: 10px;height: 38px;background: #eee;line-height:38px">${proclaname }</div>
				<input type="hidden" id="proclaId" name="proclaId" value="${proclaId }">
				<div class="proclashow" style="width: 98%;max-height:300px;position: absolute;background: white;z-index: 10;border: 1px solid #e7e7e7;border-top: none;display: none;overflow: hidden;overflow-y: auto;">
					<!-- <ul id="proclaTree"></ul> -->
					<div id="proclaTree" class="xtree_contianer">
					</div>
					<br>
					<button id="choseFw" class="layui-btn" type="button">确认</button>
					<button id="cancleFW" class="layui-btn layui-btn-primary" type="button">取消</button>
				</div>
			</div>
    	</div>
    	<div class="layui-col-md6">
	    	<label class="layui-form-label">企业网址</label>
			<div class="layui-input-block">
				<input type="text" name="website" value="${tenterprise.website}"  placeholder="请输入企业网址" autocomplete="off" class="layui-input">
			</div>
		</div>
    </div>
    <div class="layui-row rowtop">
	    <div class="layui-col-md6">
	        <label class="layui-form-label">企业QS号<span style="color: red">*</span></label>
	        <div class="layui-input-block">
	            <input type="text" name="qs" value="${tenterprise.qs}" lay-verify="required" placeholder="请输入企业QS号" autocomplete="off" class="layui-input">
	        </div>
	    </div>
	    <div class="layui-col-md6">
	        <label class="layui-form-label">企业SC号<span style="color: red">*</span></label>
	        <div class="layui-input-block">
	            <input type="text" name="sc" value="${tenterprise.sc}" lay-verify="required" placeholder="请输入企业SC号" autocomplete="off" class="layui-input">
	        </div>
	    </div>
    </div>
    <div class="layui-row rowtop">
	    <div class="layui-col-md6">
	        <label class="layui-form-label">营业执照代码<span style="color: red">*</span></label>
	        <div class="layui-input-block">
	            <input type="text" name="code" value="${tenterprise.code}"  lay-verify="required" placeholder="请输入营业执照代码" autocomplete="off" class="layui-input">
	        </div>
	    </div>
	    <div class="layui-col-md6">
	        <label class="layui-form-label">经济性质<span style="color: red">*</span></label>
	        <div class="layui-input-block">
	        	<select name="type" lay-filter="aihao">
	        		<c:forEach items="${entType }" var="ent">
	        			<option value="${ent.code }" <c:if test="${tenterprise.type==ent.code}">selected</c:if>>${ent.described }</option>
	        		</c:forEach>
				</select>
	        </div>
	    </div>
    </div>
    <div class="layui-row rowtop">
	    <div class="layui-col-md6">
	        <label class="layui-form-label">注册地址</label>
	        <div class="layui-input-block">
	            <input type="text" name="regAddress" value="${tenterprise.regAddress}" placeholder="请输入注册地址" autocomplete="off" class="layui-input">
	        </div>
	    </div>
	    <div class="layui-col-md6">
	        <label class="layui-form-label">生产地址</label>
	        <div class="layui-input-block">
	            <input type="text" name="productAddress" value="${tenterprise.productAddress}" placeholder="请输入生产地址" autocomplete="off" class="layui-input">
	        </div>
	    </div>
    </div>
    <div class="layui-row rowtop">
	    <div class="layui-col-md6">
	        <label class="layui-form-label">法人<span style="color: red">*</span></label>
	        <div class="layui-input-block">
	            <input type="text" name="legalPerson" value="${tenterprise.legalPerson}" lay-verify="required|isName" placeholder="请输入法人" autocomplete="off" class="layui-input">
	        </div>
	    </div>
	    <div class="layui-col-md6">
	        <label class="layui-form-label">联系人<span style="color: red">*</span></label>
	        <div class="layui-input-block">
	            <input type="text" name="contact" value="${tenterprise.contact}" lay-verify="required|isName" placeholder="请输入联系人" autocomplete="off" class="layui-input">
	        </div>
	    </div>
    </div>
    <div class="layui-row rowtop">
	    <div class="layui-col-md6">
	        <label class="layui-form-label">联系电话<span style="color: red">*</span></label>
	        <div class="layui-input-block">
	            <input type="text" name="phone" value="${tenterprise.phone}" lay-verify="phone|number" placeholder="请输入联系电话" autocomplete="off" class="layui-input">
	        </div>
	    </div>
	    <div class="layui-col-md6">
	        <label class="layui-form-label">电子邮箱</label>
	        <div class="layui-input-block">
	            <input type="text" id="email" name="email" value="${tenterprise.email}" placeholder="请输入电子邮箱" autocomplete="off" class="layui-input">
	        </div>
	    </div>
    </div>
    <div class="layui-row rowtop">
	    <div class="layui-col-md6">
	        <label class="layui-form-label">安全管理员<span style="color: red">*</span></label>
	        <div class="layui-input-block">
	            <input type="text" name="securityOfficer" value="${tenterprise.securityOfficer}" lay-verify="required" placeholder="请输入安全管理员" autocomplete="off" class="layui-input">
	        </div>
	    </div>
	    <div class="layui-col-md6">
	        <label class="layui-form-label">生产状态<span style="color: red">*</span></label>
	        <div class="layui-input-block">
	        	<select name="productStat" lay-filter="aihao">
	        		<c:forEach items="${produceType }" var="produce">
	        			<option value="${produce.code }" <c:if test="${tenterprise.productStat==produce.code}">selected</c:if>>${produce.described }</option>
	        		</c:forEach>
				</select>
	        </div>
	    </div>
    </div>
    <div class="layui-row rowtop">
	    <div class="layui-col-md6">
	        <label class="layui-form-label">传真</label>
	        <div class="layui-input-block">
	            <input type="text" name="fax" value="${tenterprise.fax}"  placeholder="请输入传真" autocomplete="off" class="layui-input">
	        </div>
	    </div>
	    <div class="layui-col-md6">
	        <label class="layui-form-label">邮编</label>
	        <div class="layui-input-block">
	            <input type="text" name="postcode" value="${tenterprise.postcode}"  placeholder="请输入邮编" autocomplete="off" class="layui-input" lay-verify="isPostCode">
	        </div>
	    </div>
    </div>
    <div class="layui-row rowtop">
	    <div class="layui-col-md6">
	        <label class="layui-form-label">审核时间<span style="color: red">*</span></label>
	        <div class="layui-input-block">
	        	<input type="text" id="approvalTime" name="approvalTime" value="<fmt:formatDate value='${tenterprise.approvalTime}' pattern="yyyy-MM-dd HH:mm:ss"/>" readonly="readonly" lay-verify="required" placeholder="请选择审核时间" autocomplete="off" class="layui-input">
	        </div>
	    </div>
    </div>
    <div class="layui-row rowtop">
    	<div class="layui-col-md6">
	    	<label class="layui-form-label">企业简介</label>
			<div class="layui-input-block">
				<textarea name="introduction" placeholder="请输入企业简介" class="layui-textarea">${tenterprise.introduction }</textarea>
			</div>
		</div>
    </div>
    <div class="layui-upload rowtop">
    	<div class="layui-col-md6">
	    	<label class="layui-form-label">法人身份证<span style="color: red">*</span></label>
	    	<input type="hidden" id="idcardImg" name="idcardImg" value="${tenterprise.idcardImg }">
			<input type="hidden" id="idcardTimg" name="idcardTimg" value="${tenterprise.idcardTimg }">
			<button type="button" class="layui-btn" id="idcard">选择图片</button>
			<button type="button" class="layui-btn" id="uploadIdcard">上传</button>  
			<blockquote class="layui-elem-quote layui-quote-nm" style="margin-top: 20px;">
		    	预览图：
		    <div class="layui-upload-list" id="lookcard">
		    	<div>
		    		<c:choose>
		    			<c:when test="${tenterprise.id == null}">
		    				<!-- <img style="width: 100px;height: 100px;" src="" class="layui-upload-img"> -->
		    			</c:when>
		    			<c:otherwise>
			    			<c:if test="${tenterprise.idcardTimg != nul && tenterprise.idcardTimg != '' }">
			    				<img style="width: 100px;height: 100px;" src="${ctx }/${tenterprise.idcardTimg}" class="layui-upload-img">
			    			</c:if>
		    			</c:otherwise>
		    		</c:choose>
		    	</div>
		    </div>
			</blockquote>
		</div>
		<div class="layui-col-md6">
			<label class="layui-form-label">企业LOGO</label>
	    	<input type="hidden" id="logoImg" name="logoImg" value="${tenterprise.logoImg }">
			<input type="hidden" id="logoTimg" name="logoTimg" value="${tenterprise.logoTimg }">
			<button type="button" class="layui-btn" id="logo">选择图片</button>
			<button type="button" class="layui-btn" id="uploadSubmit">上传</button>
			<blockquote class="layui-elem-quote layui-quote-nm" style="margin-top: 20px;">
		    	预览图：
		    <div class="layui-upload-list" id="looklogo">
		    	<div>
		    		<c:choose>
		    			<c:when test="${tenterprise.id == null}">
		    				<!-- <img style="width: 100px;height: 100px;" src="" class="layui-upload-img"> -->
		    			</c:when>
		    			<c:otherwise>
			    			<c:if test="${tenterprise.logoTimg != nul && tenterprise.logoTimg != '' }">
			    				<img style="width: 100px;height: 100px;" src="${ctx}/${tenterprise.logoTimg}" class="layui-upload-img">
			    			</c:if>
		    			</c:otherwise>
		    		</c:choose>
		    	</div>
		    </div>
			</blockquote>
		</div>
	</div>
	<div class="layui-row rowtop">
		<div class="layui-col-md6">
			<label class="layui-form-label">证照类型</label>
			<div class="layui-input-block" style="padding: 9px;">
				生产许可证
	            <input type="hidden" name="licenceType" value="1" autocomplete="off" class="layui-input">
	        </div>
		</div>
		<div class="layui-col-md6">
			<label class="layui-form-label">证照编号<span style="color: red">*</span></label>
			<div class="layui-input-block">
	            <input type="text" name="licenceCode" value="${licence1.licence_code }" lay-verify="required" placeholder="请输入证照编号" autocomplete="off" class="layui-input">
	        </div>
		</div>
	</div>
	<div class="layui-row rowtop">
		<div class="layui-col-md6">
			<label class="layui-form-label">发放日期<span style="color: red">*</span></label>
			<div class="layui-input-block">
				<input type="text" id="grantDate" name="grantDate" value="<fmt:formatDate value='${licence1.grant_date}' pattern="yyyy-MM-dd"/>" readonly="readonly" lay-verify="required" placeholder="请选择发放日期" autocomplete="off" class="layui-input">
	        </div>
		</div>
		<div class="layui-col-md6">
			<label class="layui-form-label">失效日期<span style="color: red">*</span></label>
			<div class="layui-input-block">
	            <input type="text" id="invalidDate" name="invalidDate" value="<fmt:formatDate value='${licence1.invalid_date}' pattern="yyyy-MM-dd"/>" readonly="readonly" lay-verify="required" placeholder="请选择失效日期" autocomplete="off" class="layui-input">
	        </div>
		</div>
	</div>
	<div class="layui-row rowtop">
    	<div class="layui-col-md6">
	    	<label class="layui-form-label">描述</label>
			<div class="layui-input-block">
				<textarea name="described" placeholder="请输入描述" class="layui-textarea">${licence1.described }</textarea>
			</div>
		</div>
    </div>
    <div class="layui-upload rowtop">
    	<label class="layui-form-label">生产许可证<span style="color: red">*</span></label>
	    	<input type="hidden" id="licenceImg" name="licenceImg" value="${licence1.licence_img }">
			<input type="hidden" id="licenceTimg" name="licenceTimg" value="${licence1.licence_timg }">
			<button type="button" class="layui-btn" id="licence">选择图片</button>
			<button type="button" class="layui-btn" id="uploadLicence">上传</button>
			<blockquote class="layui-elem-quote layui-quote-nm" style="margin-top: 20px;">
		    	预览图：
		    <div class="layui-upload-list" id="looklicence">
		    	<div>
		    		<c:choose>
		    			<c:when test="${tenterprise.id == null}">
		    				<!-- <img style="width: 100px;height: 100px;" src="" class="layui-upload-img"> -->
		    			</c:when>
		    			<c:otherwise>
		    				<c:if test="${licence1.licence_timg != nul && licence1.licence_timg != '' }">
		    					<img style="width: 100px;height: 100px;" src="${ctx }/${licence1.licence_timg }" class="layui-upload-img">
		    				</c:if>
		    			</c:otherwise>
		    		</c:choose>
		    	</div>
		    </div>
		</blockquote>
    </div>
    <div class="layui-row rowtop">
		<div class="layui-col-md6">
			<label class="layui-form-label">证照类型</label>
			<div class="layui-input-block" style="padding: 9px;">
				营业执照
	            <input type="hidden" name="licenceType2" value="2" autocomplete="off" class="layui-input">
	        </div>
		</div>
		<div class="layui-col-md6">
			<label class="layui-form-label">证照编号<span style="color: red">*</span></label>
			<div class="layui-input-block">
	            <input type="text" name="licenceCode2" value="${licence2.licence_code }" lay-verify="required" placeholder="请输入证照编号" autocomplete="off" class="layui-input">
	        </div>
		</div>
	</div>
	<div class="layui-row rowtop">
		<div class="layui-col-md6">
			<label class="layui-form-label">发放日期<span style="color: red">*</span></label>
			<div class="layui-input-block">
				<input type="text" id="grantDate2" name="grantDate2" value="<fmt:formatDate value='${licence2.grant_date}' pattern="yyyy-MM-dd"/>" readonly="readonly" lay-verify="required" placeholder="请选择发放日期" autocomplete="off" class="layui-input">
	        </div>
		</div>
		<div class="layui-col-md6">
			<label class="layui-form-label">失效日期<span style="color: red">*</span></label>
			<div class="layui-input-block">
	            <input type="text" id="invalidDate2" name="invalidDate2" value="<fmt:formatDate value='${licence2.invalid_date}' pattern="yyyy-MM-dd"/>" readonly="readonly" lay-verify="required" placeholder="请选择失效日期" autocomplete="off" class="layui-input">
	        </div>
		</div>
	</div>
	<div class="layui-row rowtop">
    	<div class="layui-col-md6">
	    	<label class="layui-form-label">描述</label>
			<div class="layui-input-block">
				<textarea name="described2" placeholder="请输入描述" class="layui-textarea">${licence2.described }</textarea>
			</div>
		</div>
    </div>
    <div class="layui-upload rowtop">
    	<label class="layui-form-label">营业执照<span style="color: red">*</span></label>
	    	<input type="hidden" id="licenceImg2" name="licenceImg2" value="${licence2.licence_img }">
			<input type="hidden" id="licenceTimg2" name="licenceTimg2" value="${licence2.licence_timg }">
			<button type="button" class="layui-btn" id="licence2">选择图片</button>
			<button type="button" class="layui-btn" id="uploadLicence2">上传</button>
			<blockquote class="layui-elem-quote layui-quote-nm" style="margin-top: 20px;">
		    	预览图：
			    <div class="layui-upload-list" id="looklicence2">
			    	<div>
				    	<c:choose>
			    			<c:when test="${tenterprise.id == null}">
			    				<!-- <img style="width: 100px;height: 100px;" src="" class="layui-upload-img"> -->
			    			</c:when>
			    			<c:otherwise>
				    			<c:if test="${licence2.licence_timg != nul && licence2.licence_timg != '' }">
				    				<img style="width: 100px;height: 100px;" src="${ctx }/${licence2.licence_timg }" class="layui-upload-img">
				    			</c:if>
			    			</c:otherwise>
			    		</c:choose>
			    	</div>
			    </div>
			</blockquote>
    </div>
    <div class="layui-form-item">
        <div class="layui-input-block">
            <button class="layui-btn" id="formBtn" lay-submit lay-filter="formDemo">立即提交</button>
            <button type="reset" class="layui-btn layui-btn-primary">重置</button>
            <button type="button" id="rollback" class="layui-btn layui-btn-primary">返回</button>
        </div>
    </div>
</form>

<script>

	layui.use(['form','layer'], function(){
	    var $ = layui.$,layer = layui.laye,form = layui.form;
	
	    form.verify({
			isName : function(value, item) { //value：表单的值、item：表单的DOM对象
				var reg = /[a-zA-Z\u4e00-\u9fa5]$/;
				if (!reg.test(value)) {
					return '只能输入中文和字母';
				}
			},isPostCode : function(value, item) { //value：表单的值、item：表单的DOM对象
				var reg =  /^[1-9][0-9]{5}$/;
				if (!reg.test(value)) {
					return '请输入正确的邮编';
				}
			},
			isWebsite : function(value, item) { //value：表单的值、item：表单的DOM对象
				var reg = /^[a-zA-Z0-9][-a-zA-Z0-9]{0,62}(\.[a-zA-Z0-9][-a-zA-Z0-9]{0,62})+\.?$/;
				if (!reg.test(value)) {
					return '请输入正确的网址';
				}
			}
		});
	    
	    /* 监听提交 */
        form.on('submit(formDemo)', function(data){
        	var isEmail = /^([a-zA-Z0-9_-])+@([a-zA-Z0-9_-])+(.[a-zA-Z0-9_-])+/;
        	var email = $('#email').val();
        	if($('#t_a_id').val() == ''){
        		alert('请选择区域');
        		return false;
        	} else if($('#t_i_id').val() == '') {
        		alert('请选择行业类别');
        		return false;
        	} else if($('#proclaId').val() == ''){
        		alert('请选择生产范围');
        		return false;
        	} else if($("#lookcard img").length == 0){
        		alert('请上传法人身份证');
        		return false;
        	} else if($("#looklicence img").length == 0){
        		alert('请上传生产许可证');
        		return false;
        	} else if($("#looklicence2 img").length == 0){
        		alert('请上传营业执照');
        		return false;
        	} else if(email != "" && !isEmail.test(email)){
        		alert('请填写正确的电子邮箱');
        		return false;
        	} else {
        		layer.load(1, {
                    shade: [0.1,'#fff'] //0.1透明度的白色背景
                });
                $("#formBtn").attr("disabled",true);
        	}
        });
	});
	 document.getElementById("rollback").addEventListener("click",function(){
         window.history.back();
      })
    layui.use(['form','laydate','tree','layer','upload'], function(){
    	//初始化
    	var $ = layui.$,layer = layui.layer,upload = layui.upload,form=layui.form;
        //主体
        $('body').click(function(e) {
            var target = $(e.target);
            // 如果#overlay或者#btn下面还有子元素，可使用
            if(!target.is('#areaname') && !target.is('.layui-tree-spread')) {
               if ( $('.areaTreeshow').is(':visible') ) {  
            	   $('.areaTreeshow').fadeOut();                                                 
               }
            }
            if(!target.is('#industryname') && !target.is('.layui-tree-spread')) {
                if ( $('.industryshow').is(':visible') ) {  
             	   $('.industryshow').fadeOut();                                                 
                }
             }
            /* console.log(target)
            if(!target.is('#proclaname') && !target.is('.proclashow')) {
                if ( $('.proclashow').is(':visible') ) {  
             	   $('.proclashow').fadeOut();                                                 
                }
             } */
        });
        /* 区域树 */
        $('.areaname').click(function(){
        	if($(".areatreeshow").is(":hidden")){
        		$('.areatreeshow').fadeIn();
        	} else {
        		$('.areatreeshow').fadeOut();
        	}
      		
      	});
   		var url = '${ctx}/enterprise/getAreaTree';
   		$.ajax({
   			type:"post",	//数据传输方式
   			url : url,		//请求路径
   			dataType:"json",	//预期服务器返回的数据类型 text,json
   			scriptCharset: 'utf-8',
   			success:function(msg){
   				layui.tree({
   					elem:'#areaTree',
   					nodes: msg,
   					click: function(node){
   						$("#t_a_id").val(node.id);
   						$("#areaname").html(node.name);
   						$(".areatreeshow").fadeOut();
   					}
   				});
   			}
   		});
    	
   		/* 行业类别树 */
        $('.industryname').click(function(){
        	if($(".industryshow").is(":hidden")){
        		$('.industryshow').fadeIn();
        	} else {
        		$('.industryshow').fadeOut();
        	}
      		
      	});
   		var url = '${ctx}/enterprise/getIndustryTree';
   		$.ajax({
   			type:"post",	//数据传输方式
   			url : url,		//请求路径
   			dataType:"json",	//预期服务器返回的数据类型 text,json
   			scriptCharset: 'utf-8',
   			success:function(msg){
   				layui.tree({
   					elem:'#industryTree',
   					nodes: msg,
   					click: function(node){
   						if(node.children==null){
   							$("#t_i_id").val(node.id);
   	   						$("#industryname").html(node.name);
   	   						$(".industryshow").fadeOut();
   						}
   					}
   				});
   			}
   		});
   	 
		//生产范围确认
   		$("#choseFw").click(function(){
   			$("#proclaname").text("");
    		$("#proclaId").val("");
    		$('.proclashow').fadeOut();
    		/* 获取生产范围树选中数据 */
        	var protitle = '';
        	var provalue = '';
        	var proclaArray = xtree1.GetChecked();
            for (var i = 0; i < proclaArray.length; i++) {
            	protitle += proclaArray[i].title + ',';
            	provalue += proclaArray[i].value + ',';
            }
            if(protitle.length > 0){
            	protitle = protitle.substring(0,protitle.length-1);
            }
            if(provalue.length > 0){
            	provalue = provalue.substring(0,provalue.length-1);
            }
            
            $("#proclaname").text(protitle);
            $("#proclaId").val(provalue);
   		});
		
   		//生产范围取消
   		$("#cancleFW").click(function(){
   			$('.proclashow').fadeOut();
   		});
   		
   		/* 生产范围树 */
   		var procalJson = [];
   		var xtree1 = new layuiXtree({
            elem: 'proclaTree',   //(必填) 放置xtree的容器，样式参照 .xtree_contianer
            form: form,    //(必填) layui 的 from
            data: []	//(必填) json数据
        });
        var url = '${ctx}/enterprise/getProclaTree';
   		$.ajax({
   			type:"post",	//数据传输方式
   			url : url,		//请求路径
   			data: {ids:$("#proclaId").val()},
   			dataType:"json",	//预期服务器返回的数据类型 text,json
   			scriptCharset: 'utf-8',
   			success:function(msg){
   				xtree1 = new layuiXtree({
   		            elem: 'proclaTree',   //(必填) 放置xtree的容器，样式参照 .xtree_contianer
   		            form: form,    //(必填) layui 的 from
   		            data: msg,	//(必填) json数据
   		         	ckall: true,	//启用全选功能，默认值：false
   		         	isopen: false	//加载完毕后的展开状态，默认值：true
   		        });
   				xtree1.render();
   			}
   		});
   		
   		$('.proclaname').click(function(){
        	if($(".proclashow").is(":hidden")){
        		$('.proclashow').fadeIn();
        	}  
      	});
   		
        /* 选择时间 */
        var laydate = layui.laydate;
        //执行一个laydate实例
        laydate.render({
            elem: '#approvalTime' //指定元素
            ,type: 'datetime'
        });
        laydate.render({
            elem: '#grantDate' //指定元素
            ,type: 'datetime'
        });
        laydate.render({
            elem: '#invalidDate' //指定元素
            ,type: 'datetime'
        });
        laydate.render({
            elem: '#grantDate2' //指定元素
            ,type: 'datetime'
        });
        laydate.render({
            elem: '#invalidDate2' //指定元素
            ,type: 'datetime'
        });
        
        /* 身份证图片上传 */
        upload.render({
	   	    elem: '#idcard'
	   	    ,url: '${ctx}/enterprise/uploadFile'
	   	    ,multiple: false	//是否开启多文件上传
	   	    ,auto:false	//是否自动上传 如果否需要使用bindAction按钮上传
  	   	    ,bindAction: '#uploadIdcard'
	   	    ,before: function(obj){
	   	    	layer.load();
	   	    },
		   	choose: function(obj) {
	             var files = this.files = obj.pushFile(); //将每次选择的文件追加到文件队列
	             obj.preview(function(index, file, result){
	            	 var div = $('#lookcard').html('<div><img style="width: 100px;height: 100px;" src="'+ result +'" alt="'+ file.name +'" class="layui-upload-img"></div>');
	             });
		   	}
	   	   ,done: function(res, index, upload){
   	    		$("#idcardImg").val(res.fileName);
   	    		$("#idcardTimg").val(res.thumbnails);
	   	    	$("#idcard").remove();
	            $("#uploadIdcard").remove();
	            
	            layer.closeAll('loading');
	   	    }
	   	  });
        
        /* 企业LOGO图片上传 */
        upload.render({
	   	    elem: '#logo'
	   	    ,url: '${ctx}/enterprise/uploadFile'
	   	    ,multiple: false	//是否开启多文件上传
	   	    ,auto:false	//是否自动上传 如果否需要使用bindAction按钮上传
  	   	    ,bindAction: '#uploadSubmit'
	   	    ,before: function(obj){
	   	    	layer.load();
	   	    },
		   	choose: function(obj) {
	             var files = this.files = obj.pushFile(); //将每次选择的文件追加到文件队列
	             obj.preview(function(index, file, result){
	            	 var div = $('#looklogo').html('<div><img style="width: 100px;height: 100px;" src="'+ result +'" alt="'+ file.name +'" class="layui-upload-img"></div>');
	             });
		   	}
	   	   ,done: function(res, index, upload){
	   	    	$("#logoImg").val(res.fileName);
	   	    	$("#logoTimg").val(res.thumbnails);
	   	    	$("#logo").remove();
	            $("#uploadSubmit").remove();
	            
	            layer.closeAll('loading');
	   	    }
	   	  });
        
        /* 生产许可证图片上传 */
        upload.render({
	   	    elem: '#licence'
	   	    ,url: '${ctx}/enterprise/uploadFile'
	   	    ,multiple: false	//是否开启多文件上传
	   	    ,auto:false	//是否自动上传 如果否需要使用bindAction按钮上传
  	   	    ,bindAction: '#uploadLicence'
	   	    ,before: function(obj){
	   	    	layer.load();
	   	    },
		   	choose: function(obj) {
	             var files = this.files = obj.pushFile(); //将每次选择的文件追加到文件队列
	             obj.preview(function(index, file, result){
	            	 var div = $('#looklicence').html('<div><img style="width: 100px;height: 100px;" src="'+ result +'" alt="'+ file.name +'" class="layui-upload-img"></div>');
	             });
		   	}
	   	   ,done: function(res, index, upload){
	   	    	$("#licenceImg").val(res.fileName);
	   	    	$("#licenceTimg").val(res.thumbnails);
	   	    	$("#licence").remove();
	            $("#uploadLicence").remove();
	            
	            layer.closeAll('loading');
	   	    }
	   	 });
        
        /* 营业执照图片上传 */
        upload.render({
	   	    elem: '#licence2'
	   	    ,url: '${ctx}/enterprise/uploadFile'
	   	    ,multiple: false	//是否开启多文件上传
	   	    ,auto:false	//是否自动上传 如果否需要使用bindAction按钮上传
  	   	    ,bindAction: '#uploadLicence2'
	   	    ,before: function(obj){
	   	    	layer.load();
	   	    },
		   	choose: function(obj) {
	             var files = this.files = obj.pushFile(); //将每次选择的文件追加到文件队列
	             obj.preview(function(index, file, result){
	            	 var div = $('#looklicence2').html('<div><img style="width: 100px;height: 100px;" src="'+ result +'" alt="'+ file.name +'" class="layui-upload-img"></div>');
	             });
		   	}
	   	   ,done: function(res, index, upload){
	   	    	$("#licenceImg2").val(res.fileName);
	   	    	$("#licenceTimg2").val(res.thumbnails);
	   	    	$("#licence2").remove();
	            $("#uploadLicence2").remove();
	            
	            layer.closeAll('loading');
	   	    }
	   	  });
    });
</script>
</body>
</html>


